<template>
  <common-page title="详情">
    <el-button slot="header" @click="back">返回</el-button>
    <div slot="content" class="notice-wrap">
      <detail-content :detail="detail" v-loading="loading"></detail-content>
    </div>
  </common-page>
</template>

<script>
import DetailContent from "./detailContent.vue";
import { fetchPublicInfo, fetchInfoDetail } from "@/api/system/publicNotice";
export default {
  components: {
    DetailContent,
  },
  props: {
    isPublicManage: {
      type: Boolean,
      default: true,
    },
    noticeId: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      detail: {},
      loading: false,
    };
  },
  mounted() {
    this.loading = true;
    if (this.isPublicManage) {
      //管理中心 公告管理
      fetchPublicInfo({ noticeId: this.noticeId })
        .then((res) => {
          if (res && res.code === 200) {
            this.detail = res.data || {};
          }
        })
        .finally(() => {
          this.loading = false;
        });
    } else {
      fetchInfoDetail({ noticeId: this.noticeId })
        .then((res) => {
          if (res && res.code === 200) {
            this.detail = res.data || {};
            //获取通知个数
            // this.$bus.$emit("messageList");
          }
        })
        .finally(() => {
          this.loading = false;
        });
    }
  },

  methods: {
    back() {
      this.$emit("back");
    },
  },
  
};
</script>
<style lang="scss" scoped>
.notice-wrap {
  width: 65%;
  margin: auto;
  margin-top: 30px;
  height: calc(100% - 70px);
  box-shadow: 0 1px 8px 0 rgb(0 0 0 / 5%);
  border: 1px solid #eee;
  border-radius: 4px;
}
</style>
